#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int x,y,t;
	scanf("%d %d", &x, &y);
	while (y)
	{
		t = x%y;
		x = y;
		y = t;
	}
	printf("%d", x);
	return 0;
}